package java36;

import java.util.*;
import java.text.*;
public class Java36 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		List<Person> personList = new ArrayList<Person>();
		while(in.hasNext()){
			String str = new String(in.next());
			if(str.equals("s"))
				personList.add(new Student(in.next(),in.nextInt(),in.nextBoolean(),in.next(),in.nextLine()));
			else if(str.equals("e"))
				personList.add(new Employee(in.next(),in.nextInt(),in.nextBoolean(),in.nextDouble(),new Company(in.nextLine())));
			else
				{in.nextLine();break;}
		}
		Collections.sort(personList);
		for (Person person : personList) {
			System.out.println(person);
		}
		String s = new String(in.nextLine());
		if(s.equals("exit"))
			System.exit(0);
		else{
			List<Student> stuList = new ArrayList<Student>();
			List<Employee> empList = new ArrayList<Employee>();
			for (int j = 0; j < personList.size(); j++) {
				if(personList.get(j).getClass().getName().equals(Student.class.getName())){
					if(!stuList.contains((Student)personList.get(j)))
					stuList.add((Student)personList.get(j));
				}
				else{
					if(!empList.contains((Employee)personList.get(j)))
						empList.add((Employee)personList.get(j));
				}
			}
			
			System.out.println("stuList");
			for (Student stu : stuList) {
				System.out.println(stu);
			}
			System.out.println("empList");
			for (Employee emp : empList) {
				System.out.println(emp);
			}
		}
			
	}
}
abstract class Person implements Comparable{
	public String name;
	public int age;
	public boolean gender;

	public Person(String name, int age, boolean gender) {
		this.name = name;
		this.age = age;
		this.gender = gender;
	}
	
	public int compareTo(Object o) {
		Person p = (Person)o;
		int otherAge = p.getAge();
		String otherName = p.getName();
		if(this.name.compareTo(otherName)!=0)
			return this.name.compareTo(otherName);
		else{
				if(this.age>=otherAge)
					return 1;
				else if(this.age<=otherAge)
					return -1;
				else
					return 0;
		}
	}
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public boolean getGender() {
		return gender;
	}

	public void setGender(boolean gender) {
		this.gender = gender;
	}
	public String toString() {
		return name + "-" + age + "-" + gender;
	}
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Person other = (Person) obj;
		if (age != other.age)
			return false;
		if (gender != other.gender)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
}

class Student extends Person{
	private String stuNo;
	private String clazz;

	public Student(String name, int age, boolean gender,String stuNo,String clazz) {
		super(name, age, gender);
		this.stuNo = stuNo;
		this.clazz = clazz;
	}

	public String toString() {
		return "Student:"+super.toString() + "-" + stuNo + "-"+clazz;
	}
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Student other = (Student) obj;
		if (clazz == null) {
			if (other.clazz != null)
				return false;
		} else if (!clazz.equals(other.clazz))
			return false;
		if (stuNo == null) {
			if (other.stuNo != null)
				return false;
		} else if (!stuNo.equals(other.stuNo))
			return false;
		return true;
	}
}
class Company{
	
	private String name;
	public Company(String name) {
		this.name = name;
	}
	public String toString() {
		return name;
	}
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Company other = (Company) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
}
class Employee extends Person{
	private Company company;
	private double salary;
	DecimalFormat df = new DecimalFormat("#.#");
	public Employee(String name,int age, boolean gender, double salary, Company company) {
		super(name, age, gender);
		this.salary = salary;
		this.company = company;
	}
	
	public Company getCompany() {
		return company;
	}
	public void setCompany(Company company) {
		this.company = company;
	}
	public double getSalary() {
		return salary;
	}
	public void setSalary(double salary) {
		this.salary = salary;
	}
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Employee other = (Employee) obj;
		if (company == null) {
			if (other.company != null)
				return false;
		} else if (!company.equals(other.company))
			return false;
		if (!df.format(salary).equals(df.format(other.salary)))
			return false;
		return true;
	}

	public String toString() {
		return "Employee:"+super.toString()+"-"+ company + "-" +salary;
	}
}